package Image;

import java.awt.RenderingHints;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.ParameterBlock;
import java.awt.image.renderable.RenderedImageFactory;
import javax.media.jai.ROI;

/**
 * An <code>RIF</code> supporting the "Centroid" operation in the
 * rendered image layer.
 */
public class CentroidRIF implements  RenderedImageFactory {

	/** Constructor. */
	public CentroidRIF() {}

	/**
	 * Creates a new instance of <code>CentroidOpImage</code>
	 * in the rendered layer. Any image layout information in
	 * <code>RenderingHints</code> is ignored.
	 * This method satisfies the implementation of RIF.
	 */
	public RenderedImage create(
		ParameterBlock paramBlock,RenderingHints renderHints
	) {
		RenderedImage src = paramBlock.getRenderedSource(0);

		int xStart = src.getMinX(); // default values
		int yStart = src.getMinY();

		int maxWidth = src.getWidth();
		int maxHeight = src.getHeight();

		return new CentroidOpImage(src, (ROI) paramBlock
				.getObjectParameter(0), xStart, yStart, 1,1);
	}
}
